package com.example.schedule.views

import android.content.Context
import androidx.annotation.StyleRes
import androidx.appcompat.app.AlertDialog
import com.example.schedule.R
import com.example.schedule.databinding.DialogScheduleBinding

/**
 *Create by Fanketly on 2021/11/5
 *Gitee:https://gitee.com/fanketly
 */

fun newDialog(
    context: Context,
    @StyleRes style: Int = 0,
    unit: (binding: DialogScheduleBinding, dialog: AlertDialog) -> Unit
) {
    val dialog = AlertDialog.Builder(context, style).create()
    val binding = DialogScheduleBinding.inflate(dialog.layoutInflater)
    dialog.window?.setBackgroundDrawableResource(R.drawable.shape16)
    dialog.setView(binding.root)
    unit(binding, dialog)
}